< previous page page_505 next page >

Page 505
This test data can exercise defined relationships, check for data table integrity, and so on. Using an SQL script to load data is an excellent way to perform repeated tests on changing data tables. As you make changes to your table structures, you can use the same data each time until you know you have the results you are looking for.
Also, you can use the same SQL statements to create data tables within other database systems, including Microsoft's SQL Server, Oracle, and others. After you create the test files using Microsoft Access Jet databases, you can then regenerate the tables for other database engines using the same SQL statements. This increases the portability of your application and eases the migration of your data from one database platform to another.
Table Management SQL Keywords
The type of SQL keywords you learn today are the table management keywords. These keywords enable you to create new data tables, alter the structure of existing data tables, and remove existing data tables from the database.
Designing New Tables with CREATE TABLE
The CREATE TABLE keyword allows you to create new tables in an existing database. In its most basic form, the CREATE TABLE statement consists of three parts: the CREATE TABLE clause; a TableName; and a list of column names, column types, and column sizes for each column in the new table. The following example shows a simple CREATE TABLE SQL statement.
CREATE TABLE NewTable (Field1 TEXT(30), Field2 INTEGER);
This SQL statement creates a data table called NewTable that has two columns. The column named Field1 is a TEXT column 30 bytes long. The column named Field2 is an INTEGER column. Notice that no size was designated for the INTEGER column. Microsoft Access Jet SQL statements only accept size values for TEXT columns. All other columns are set to a predefined length. See Table 2.1 in Day 2, "Creating Databases," for a list of the default field lengths for Microsoft Access Jet data fields.
Note.gif
If you omit the size definition for the TEXT field, Microsoft Access Jet uses the default value of 255 bytes. Because this can result in rather large tables with empty space, it's a good habit to declare a size for all TEXT fields.

 
< previous page page_505 next page >

If you like this book, buy it!